package com.smart.web.controller;

import java.util.Date;
import java.util.Enumeration;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.smart.util.SimpleHttpClient;

@Controller
public class TestController extends BaseController{
	@RequestMapping(value = "test/test")
	public @ResponseBody String test(HttpServletRequest req){
		String ua = req.getHeader("User-Agent");
		Enumeration<String> headerNames = req.getHeaderNames();
		while(headerNames.hasMoreElements()) {
			String headerName = headerNames.nextElement();
			String val = req.getHeader(headerName);
			System.out.println(headerName + ":" + val);
		}
		//System.out.println(ua);
		return "OK";
	}
	
	public static void main(String[] args) {
		SimpleHttpClient client = new SimpleHttpClient();
		String ua = "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16C101 NebulaSDK/1.8.100112 Nebula PSDType(1) AlipayDefined(nt:WIFI,ws:414|672|3.0) AliApp(AP/10.1.55.6001) AlipayClient/10.1.55.6001 Alipay Language/zh-Hans";
		SimpleHttpClient.HttpReq req = new SimpleHttpClient.HttpReq();
		req.addHeader("User-Agent", ua);
		req.addHeader("connection", "keep-alive");
		req.addHeader("ts", new Date().getTime() + "");
		req.addHeader("upgrade-insecure-requests", "1");
		req.addHeader("accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
		req.addHeader("user-agent", "Mozilla/5.0 (iPhone; CPU iPhone OS 12_1_2 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/16C101 NebulaSDK/1.8.100112 Nebula PSDType(1) AlipayDefined(nt:WIFI,ws:414|672|3.0) AliApp(AP/10.1.55.6001) AlipayClient/10.1.55.6001 Alipay Language/zh-Hans");
		req.addHeader("accept-language", "zh-cn");
		req.addHeader("accept-encoding", "gzip, deflate");
		//req.setUrl("http://admin.php05.cn/pay/index/alipay?ms=OID=15477220874907&t=1547722087&tk=a53f9db256e66e4e");
		http://www.m6143.cn/pp2.php?money=0.88&userId=2088102012636908&memo=2019011817124744245
			req.setUrl("http://www.m6143.cn/pp2.php?money=0.88&userId=2088102012636908&memo=2019011817124744245");
		SimpleHttpClient.HttpResp resp = client.doGet(req);
		System.out.println(resp.getContent());
		
	}
	
}
